package batch.process;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;

import batch.process.utils.BatchProcessLogger;


public class BaseBatchProcess {

	protected static BatchProcessLogger logger = null;	
	protected static HashMap<String, String> parameters = null;
	
	protected static void init() {
		logger = new BatchProcessLogger();
		parameters = new HashMap<String, String>();
	}
	
	protected static void getParameters(String[] args) {
		if (args.length > 0){			
			List<String> params = new ArrayList<String>(Arrays.asList(args));
			
			// Verifica os parametros
			Iterator<String> paramsI = params.iterator();
			while(paramsI.hasNext()){
				String atual = paramsI.next();
				if (atual.startsWith("-")){
					// isola o tipo de parametro
					String tipo = atual.substring(1).toLowerCase();
					paramsI.remove();
					
					// isola o valor do parametro
					String valor = paramsI.next();
					paramsI.remove();
					
					parameters.put(tipo, valor);
				}
			}				
		}
	}	
}
